<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>仿有道词典</title>
<link href="css/mui.css" rel="stylesheet"/>
<link href="css/style.css" rel="stylesheet"/>
</head>
<body>
<div class="mui-content">
    <div class="mui-slider">
	  <div class="mui-slider-group  mui-slider-loop" id="slider"></div>
	  <div class="mui-slider-indicator" id="point"></div>
	</div>
	<div class="newsList">
		<ul id="newsListUl">
		</ul>
	</div>
</div>

<script src="js/mui.min.js"></script>	
<script src="js/h.js"></script>
<script type="text/javascript" charset="utf-8">
mui.init();
var _index, _self, _next;
mui.plusReady(function(){
	//获取轮播内容
	mui.get(
		'http://hoa.hcoder.net/index.php?user=hcoder&pwd=hcoder&m=lunbo',
		function(res){
			var items = res.split('--hcSplitor--');//图片分割
			var html = '<div class="mui-slider-item"><a href="#">'+items[items.length - 1]+'</a></div>';
			var points='';
			for(var i = 0; i < items.length; i++){
	            html += '<div class="mui-slider-item"><a href="#">'+items[i]+'</a></div>';
	            points +='<div class="mui-indicator"></div>'
	        }
			html +='<div class="mui-slider-item"><a href="#">'+items[0]+'</a></div>';
	        h('#slider').html(html);
	        h('#point').html(points);
	        var gallery = mui('.mui-slider');
			gallery.slider({
				interval:5000//自动轮播周期，若为0则不自动播放，默认为0；
			});
		}
	);
	//获取新闻列表
	mui.get(
		'http://hoa.hcoder.net/index.php?user=hcoder&pwd=hcoder&m=mediaList&page=1',
		function(res){
			var newsLists = res.split('--hcSplitor--');//外层分割
			var html ='';
			for(var i = 0; i < newsLists.length; i++){
				var newsItem = newsLists[i].split('--hcListSplitor--');
				html += '<li><a href="javascript:openInfo('+newsItem[0]+');"><div class="imgs"><img src="'+newsItem[1]+'"/></div><div class="title">'+newsItem[2]+'</div></a></li>'
			}
			h("#newsListUl").html(html);
		}
	)
    _self = plus.webview.currentWebview();
    _next = plus.webview.getWebviewById('sub2.html');
    _index = plus.webview.getLaunchWebview();
    _self.drag(
        {
            direction : "left",
            moveMode :　"followFinger"
        },
        {
            view :　_next,
            moveMode : "follow"
        },
        //执行回调函数
        function(e){
        	//console.log(JSON.stringify(e));
        	if(e.type == 'end' && e.result){
				_index.evalJS("h('#tabBar').find('a').removeClass('mui-active'); h('#nav2').addClass('mui-active');");
			}
        }
    );
});
function openInfo(id){
	console.log(id);
	mui.openWindow({
	    url:'info.html',
	    id:'info.html',
	    extras:{
	      newsId : id
	    }
	})
}
</script>
</body>
</html>